import request from "@/router/axios";

export const getProductList = (params) => {
  return request({
    url: "/admin/product/pageList",
    method: "get",
    params: { ...params },
  });
};

export const updateProductItem = (row) => {
  return request({
    url: "/admin/product/saveProduct",
    method: "post",
    data: row,
  });
};

export const delProductItem = (row) => {
  return request({
    url: "/admin/product/delete",
    method: "post",
    data: row,
  });
};

export const getProductItemDetail = (params) => {
  return request({
    url: "/admin/product/detail",
    method: "get",
    params: { ...params },
  });
};



export const setProductItemStatus = (row) => {
  return request({
    url: "/admin/product/updateStatus",
    method: "post",
    data: row,
  });
};

export const getProductSkuInfo = (row) => {
  return request({
    url: "/admin/product/generateSkuCombinations",
    method: "post",
    data: row,
  });
};

// 上传
export const uploadFile = (params) => {
  const formData = new FormData();
  formData.append('file', params.file);
  // if(params.id) {
  //   formData.append('id', params.id);
  // }
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/admin/common/upload",
    method: "post",
    data: formData,
  });
};